package com.jl.jlapp.mvp.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter.OnItemChildClickListener;
import com.jl.jlapp.R;
import com.jl.jlapp.adapter.EvaluationPicAdapter;
import com.jl.jlapp.eneity.EvaluationDetailByUserIdAndIdModel;
import com.jl.jlapp.eneity.EvaluationDetailByUserIdAndIdModel.ResultDataBean.EvaluationPicsBean;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import com.jl.jlapp.utils.CustomGridLayoutManager;
import com.jl.jlapp.utils.Tools;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import java.util.ArrayList;
import java.util.List;

public class EvalSubmitSuccessActivity
        extends AppCompatActivity {
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.edit_evaluation_content)
    TextView edit_evaluation_content;
    EvaluationPicAdapter evaluationPicAdapter;
    List<EvaluationDetailByUserIdAndIdModel.ResultDataBean.EvaluationPicsBean> evaluationPicsBeans = new ArrayList();
    @BindView(R.id.evaluation_star1)
    ImageView evaluationStar1;
    @BindView(R.id.evaluation_star2)
    ImageView evaluationStar2;
    @BindView(R.id.evaluation_star3)
    ImageView evaluationStar3;
    @BindView(R.id.evaluation_star4)
    ImageView evaluationStar4;
    @BindView(R.id.evaluation_star5)
    ImageView evaluationStar5;
    int id = 0;
    @BindView(R.id.goods_eval_img_recycler_view)
    RecyclerView imgRecyclerView;
    int orderDetailNum = 0;
    String orderDetailPic = "";
    int orderId = 0;
    int score = 0;
    @BindView(R.id.should_evaluation_goods_img)
    ImageView shouldEvaluationGoodsImg;
    int userId = 0;

    private void initStars(int paramInt) {
        this.evaluationStar1.setImageResource(R.drawable.star_gray);
        this.evaluationStar2.setImageResource(R.drawable.star_gray);
        this.evaluationStar3.setImageResource(R.drawable.star_gray);
        this.evaluationStar4.setImageResource(R.drawable.star_gray);
        this.evaluationStar5.setImageResource(R.drawable.star_gray);
        switch (paramInt) {

            case 1:
                this.evaluationStar1.setImageResource(R.drawable.star_yellow);
                break;
            case 2:
                this.evaluationStar1.setImageResource(R.drawable.star_yellow);
                this.evaluationStar2.setImageResource(R.drawable.star_yellow);
                break;
            case 3:
                this.evaluationStar1.setImageResource(R.drawable.star_yellow);
                this.evaluationStar2.setImageResource(R.drawable.star_yellow);
                this.evaluationStar3.setImageResource(R.drawable.star_yellow);
                break;
            case 4:
                this.evaluationStar1.setImageResource(R.drawable.star_yellow);
                this.evaluationStar2.setImageResource(R.drawable.star_yellow);
                this.evaluationStar3.setImageResource(R.drawable.star_yellow);
                this.evaluationStar4.setImageResource(R.drawable.star_yellow);
                break;
            default:
                this.evaluationStar1.setImageResource(R.drawable.star_yellow);
                this.evaluationStar2.setImageResource(R.drawable.star_yellow);
                this.evaluationStar3.setImageResource(R.drawable.star_yellow);
                this.evaluationStar4.setImageResource(R.drawable.star_yellow);
                this.evaluationStar5.setImageResource(R.drawable.star_yellow);
                break;
        }

    }

    public void getNetData() {
        if ((this.id != 0) && (this.orderDetailNum != 0)) {
            Net.get().getEvaluationDetailByUserIdAndId(this.id, this.userId).subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread()).subscribe(new CommonObserver<EvaluationDetailByUserIdAndIdModel>() {
                @Override
                protected void onError(String errorMsg) {

                }

                @Override
                protected void onSuccess(EvaluationDetailByUserIdAndIdModel evaluationDetailByUserIdAndIdModel) {

                }
            });
            return;
        }
        Toast.makeText(this, "页面传值没有接收到", Toast.LENGTH_SHORT).show();
    }

    public void imgSetAdapter() {
        this.imgRecyclerView.setLayoutManager(new CustomGridLayoutManager(this, 5, false));
        this.evaluationPicAdapter = new EvaluationPicAdapter(R.layout.after_sale_img_item, this.evaluationPicsBeans);
        this.imgRecyclerView.setAdapter(this.evaluationPicAdapter);
        this.evaluationPicAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            public void onItemChildClick(BaseQuickAdapter paramAnonymousBaseQuickAdapter, View paramAnonymousView, int paramAnonymousInt) {
                Intent intent = new Intent(EvalSubmitSuccessActivity.this, PhotoViewActivity.class);
                intent.putExtra("picUrl", ((EvaluationDetailByUserIdAndIdModel.ResultDataBean.EvaluationPicsBean) EvalSubmitSuccessActivity.this.evaluationPicsBeans.get(paramAnonymousInt)).getPicUrl());
                EvalSubmitSuccessActivity.this.startActivity(intent);
            }
        });
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.fragment_eval_submit_success);
        ButterKnife.bind(this);
        Tools.finishAll();
        Tools.addActivity(this);
        this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", -1);
        Intent intent = getIntent();
        this.id = intent.getIntExtra("id", 0);
        this.orderDetailNum = intent.getIntExtra("orderDetailNum", 0);
        this.orderDetailPic = intent.getStringExtra("orderDetailPic");
        this.orderId = intent.getIntExtra("orderId", 0);
        Glide.with(this).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load("http://117.158.178.202:8001/JLMIS/" + this.orderDetailPic).into(this.shouldEvaluationGoodsImg);
        getNetData();
        this.back.setOnClickListener(new OnClickListener() {
            public void onClick(View paramAnonymousView) {
                if ((EvalSubmitSuccessActivity.this.orderDetailNum == 0) && (EvalSubmitSuccessActivity.this.orderId == 0)) {
                    EvalSubmitSuccessActivity.this.finish();
                    return;
                }
                if (EvalSubmitSuccessActivity.this.orderDetailNum == 1) {
                    Intent intentOrder = new Intent(EvalSubmitSuccessActivity.this, MyOrderListActivity.class);
                    EvalSubmitSuccessActivity.this.startActivity(intentOrder);
                    EvalSubmitSuccessActivity.this.finish();
                    return;
                }
                Tools.addActivity(EvalSubmitSuccessActivity.this);
                Intent intentValue = new Intent(EvalSubmitSuccessActivity.this, ShouldEvaluationActivity.class);
                intentValue.putExtra("orderId", EvalSubmitSuccessActivity.this.orderId);
                EvalSubmitSuccessActivity.this.startActivity(intentValue);
                Tools.finishAll();
            }
        });
    }

    public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent) {
        if ((paramInt == 4) && (paramKeyEvent.getRepeatCount() == 0)) {
            if ((this.orderDetailNum == 0) && (this.orderId == 0)) {
                finish();
            }
            if (this.orderDetailNum == 1) {
                startActivity(new Intent(this, MyOrderListActivity.class));
                finish();
                return true;
            }
            Intent intent = new Intent(this, ShouldEvaluationActivity.class);
            intent.putExtra("orderId", this.orderId);
            startActivity(intent);
            finish();
            return true;
        }
        return super.onKeyDown(paramInt, paramKeyEvent);
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/EvalSubmitSuccessActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */